package ZZ;
$Mojo::Webqq::Plugin::MJ::PRIORITY = 1;
use Encode;


sub jiequ {

my ($str, $size) = @_;

    my ($str, $size) = @_;
    my $tm = 0;
    if (length($str) <= $maxlen) {
      push @{$sstr},$str;
      return $sstr;

     }
    my $mystr= substr($str,0,$size);
       $mystr =~ s/[^\x7f-\xff]//g;
       $tm = length($mystr) % 3;
    my $retval = substr($str,0,$size-$tm);
    push  @{$sstr},$retval;
    return jiequ(substr($str,$size-$tm),$size);
}

my $shidb='ZZDB';
open my $SFD,"<",$shidb or warn "file @!";
my @shi=<$SFD>;
close $SFD;
my $shidb ;
my $shi300= \@shi;
sub call {
    my $client = shift;
    $client->on(receive_message=>sub{
        my($client,$msg)=@_;
        return if not $msg->allow_plugin;
         return if $msg->content !~ /(庄\s*子|庄周|逍遥游|南华经)/;
          my $shiwen = $shi300->[int rand(358+1)];
          my $sstr;
          my $result=jiequ($shiwen,500);
          pop @{$result};
          my $num=@{$result};
          unless($num>2){
             $msg->reply($result->[0],sub{$_[1]->from("bot")}) if($num==2);
              my $replyad =$result->[-1]." (源于Mojo-Webqq桔子庄子子机器人插件)";
             $msg->reply($replyad,sub{$_[1]->from("bot")});

           }else{
          $msg->reply($result->[$_],sub{$_[1]->from("bot")}) for(0..$num-2);
          my $replyad =$result->[-1]." (源于Mojo-Webqq桔子庄子子机器人插件)";
          $msg->reply($replyad,sub{$_[1]->from("bot")});
          }
          @{$result}=();
        #$client->reply_message($msg,$reply,sub{$_[1]->msg_from("bot")}) if $reply;
    });
}
1;
=cut

